package frame.options.physicalNetworks.create;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentListener;

import model.components.links.factory.PhysicalLinksFactory;
import model.components.networks.factory.PhysicalNetworksFactory;
import model.components.nodes.factory.PhysicalNodesFactory;

@SuppressWarnings("serial")
public class CreatePhysicalNetworksSelectPanel extends JPanel 
{	
	private JLabel networksNumberLabel;
	public JLabel getNetworksNumberLabel(){ return networksNumberLabel; }
	public void setNetworksNumberLabel( JLabel networksNumberLabel ){ this.networksNumberLabel = networksNumberLabel; }
	
	private JTextField networksNumberTextField;
	public JTextField getNetworksNumberTextField(){ return networksNumberTextField; }
	public void setNetworksNumberTextField( JTextField networksNumberTextField ){ this.networksNumberTextField = networksNumberTextField; }
	
	private JLabel nodesNumberLabel;
	public JLabel getNodesNumberLabel(){ return nodesNumberLabel; }
	public void setNodesNumberLabel( JLabel nodesNumberLabel ){ this.nodesNumberLabel = nodesNumberLabel; }
	
	private JTextField minNodesNumberTextField;
	public JTextField getMinNodesNumberTextField(){ return minNodesNumberTextField; }
	public void setMinNodesNumberTextField( JTextField minNodesNumberTextField ){ this.minNodesNumberTextField = minNodesNumberTextField; }
	
	private JTextField maxNodesNumberTextField;
	public JTextField getMaxNodesNumberTextField(){ return maxNodesNumberTextField; }
	public void setMaxNodesNumberTextField( JTextField maxNodesNumberTextField ){ this.maxNodesNumberTextField = maxNodesNumberTextField; }
	
	private JLabel typesNodePercentagesLabel;
	public JLabel getTypesNodePercentagesLabel(){ return typesNodePercentagesLabel; }
	public void setTypesNodePercentagesLabel( JLabel typesNodePercentagesLabel ){ this.typesNodePercentagesLabel = typesNodePercentagesLabel; }
	
	private JTextField routersPercentageTextField;
	public JTextField getRoutersPercentageTextField(){ return routersPercentageTextField; }
	public void setRoutersPercentageTextField( JTextField routersPercentageTextField ){ this.routersPercentageTextField = routersPercentageTextField; }

	private JTextField switchesPercentageTextField;
	public JTextField getSwitchesPercentageTextField(){ return switchesPercentageTextField; }
	public void setSwitchesPercentageTextField( JTextField switchesPercentageTextField ){ this.switchesPercentageTextField = switchesPercentageTextField; }
	
	private JTextField serversPercentageTextField;
	public JTextField getServersPercentageTextField(){ return serversPercentageTextField; }
	public void setServersPercentageTextField( JTextField serversPercentageTextField ){ this.serversPercentageTextField = serversPercentageTextField; }
	
	private JLabel operatingSystemsLabel;
	public JLabel getOperatingSystemsLabel(){ return operatingSystemsLabel; }
	public void setOperatingSystemsLabel( JLabel operatingSystemsLabel ){ this.operatingSystemsLabel = operatingSystemsLabel; }
	
	private JTextField linuxPercentageTextField;
	public JTextField getLinuxPercentageTextField(){ return linuxPercentageTextField; }
	public void setLinuxPercentageTextField( JTextField linuxPercentageTextField ){ this.linuxPercentageTextField = linuxPercentageTextField; }

	private JTextField windowsPercentageTextField;
	public JTextField getWindowsPercentageTextField(){ return windowsPercentageTextField; }
	public void setWindowsPercentageTextField( JTextField windowsPercentageTextField ){ this.windowsPercentageTextField = windowsPercentageTextField; }
	
	private JTextField solarisPercentageTextField;
	public JTextField getSolarisPercentageTextField(){ return solarisPercentageTextField; }
	public void setSolarisPercentageTextField( JTextField solarisPercentageTextField ){ this.solarisPercentageTextField = solarisPercentageTextField; }

	private JTextField androidPercentageTextField;
	public JTextField getAndroidPercentageTextField(){ return androidPercentageTextField; }
	public void getAndroidPercentageTextField( JTextField androidPercentageTextField ){ this.androidPercentageTextField = androidPercentageTextField; }

	private JLabel virtualEnvironmentsLabel;
	public JLabel getVirtualEnvironmentsLabel(){ return virtualEnvironmentsLabel; }
	public void setVirtualEnvironmentsLabel( JLabel virtualEnvironmentsLabel ){ this.virtualEnvironmentsLabel = virtualEnvironmentsLabel; }
	
	private JTextField vmWarePercentageTextField;
	public JTextField getVmWarePercentageTextField(){ return vmWarePercentageTextField; }
	public void setVmWarePercentageTextField( JTextField vmWarePercentageTextField ){ this.vmWarePercentageTextField = vmWarePercentageTextField; }

	private JTextField xenPercentageTextField;
	public JTextField getXenPercentageTextField(){ return xenPercentageTextField; }
	public void setXenPercentageTextField( JTextField xenPercentageTextField ){ this.xenPercentageTextField = xenPercentageTextField; }
	
	private JTextField kvmPercentageTextField;
	public JTextField getKvmPercentageTextField(){ return kvmPercentageTextField; }
	public void getKvmPercentageTextField( JTextField kvmPercentageTextField ){ this.kvmPercentageTextField = kvmPercentageTextField; }
	
	private JTextField umlPercentageTextField;
	public JTextField getUmlPercentageTextField(){ return umlPercentageTextField; }
	public void getUmlPercentageTextField( JTextField umlPercentageTextField ){ this.umlPercentageTextField = umlPercentageTextField; }
	
	private JRadioButton linksNumberPercentageRadioButton;
	public JRadioButton getLinksNumberPercentageRadioButton(){ return linksNumberPercentageRadioButton; }
	public void setLinksNumberPercentageRadioButton( JRadioButton linksNumberPercentageRadioButton ){ this.linksNumberPercentageRadioButton = linksNumberPercentageRadioButton; }

	private JTextField linksNumberPercentageTextField;
	public JTextField getLinksNumberPercentageTextField(){ return linksNumberPercentageTextField; }
	public void setLinksNumberPercentageTextField( JTextField linksNumberPercentageTextField ){ this.linksNumberPercentageTextField = linksNumberPercentageTextField; }
	
	private JRadioButton linksNumberRangeRadioButton;
	public JRadioButton getLinksNumberRangeRadioButton(){ return linksNumberRangeRadioButton; }
	public void setLinksNumberRangeRadioButton( JRadioButton linksNumberRangeRadioButton) { this.linksNumberRangeRadioButton = linksNumberRangeRadioButton; }
	
	private JTextField minLinksNumberTextField;
	public JTextField getMinLinksNumberTextField(){ return minLinksNumberTextField; }
	public void setMinLinksNumberTextField( JTextField minLinksNumberTextField ){ this.minLinksNumberTextField = minLinksNumberTextField; }

	private JTextField maxLinksNumberTextField;
	public JTextField getMaxLinksNumberTextField(){ return maxLinksNumberTextField; }
	public void setMaxLinksNumberTextField( JTextField maxLinksNumberTextField ){ this.maxLinksNumberTextField = maxLinksNumberTextField; }
	
	private JLabel cpuLabel;
	public JLabel getCpuLabel(){ return cpuLabel; }
	public void setCpuLabel( JLabel cpuLabel ){ this.cpuLabel = cpuLabel; }
	
	private JTextField minCpuTextField;
	public JTextField getMinCpuTextField(){ return minCpuTextField; }
	public void setMinCpuTextField( JTextField minCpuTextField ){ this.minCpuTextField = minCpuTextField; }
	
	private JTextField maxCpuTextField;
	public JTextField getMaxCpuTextField(){ return maxCpuTextField; }
	public void setMaxCpuTextField( JTextField maxCpuTextField ){ this.maxCpuTextField = maxCpuTextField; }
	
	private JLabel cpuUnitPriceLabel;
	public JLabel getCpuUnitPriceLabel(){ return cpuUnitPriceLabel; }
	public void setCpuUnitPriceLabel( JLabel cpuUnitPriceLabel ){ this.cpuUnitPriceLabel = cpuUnitPriceLabel; }
	
	private JTextField minCpuUnitPriceTextField;
	public JTextField getMinCpuUnitPriceTextField(){ return minCpuUnitPriceTextField; }
	public void setMinCpuUnitPriceTextField( JTextField minCpuUnitPriceTextField ){ this.minCpuUnitPriceTextField = minCpuUnitPriceTextField; }
	
	private JTextField maxCpuUnitPriceTextField;
	public JTextField getMaxCpuUnitPriceTextField(){ return maxCpuUnitPriceTextField; }
	public void setMaxCpuUnitPriceTextField( JTextField maxCpuUnitPriceTextField ){ this.maxCpuUnitPriceTextField = maxCpuUnitPriceTextField; }
	
	private JLabel memoryLabel;
	public JLabel getMemoryLabel(){ return memoryLabel; }
	public void setMemoryLabel( JLabel memoryLabel ){ this.memoryLabel = memoryLabel; }
	
	private JTextField minMemoryTextField;
	public JTextField getMinMemoryTextField(){ return minMemoryTextField; }
	public void setMinMemoryTextField( JTextField minMemoryTextField ){ this.minMemoryTextField = minMemoryTextField; }
	
	private JTextField maxMemoryTextField;
	public JTextField getMaxMemoryTextField(){ return maxMemoryTextField; }
	public void setMaxMemoryTextField( JTextField maxMemoryTextField ){ this.maxMemoryTextField = maxMemoryTextField; }

	private JLabel memoryUnitPriceLabel;
	public JLabel getMemoryUnitPriceLabel(){ return memoryUnitPriceLabel; }
	public void setMemoryUnitPriceLabel( JLabel memoryUnitPriceLabel ){ this.memoryUnitPriceLabel = memoryUnitPriceLabel; }
	
	private JTextField minMemoryUnitPriceTextField;
	public JTextField getMinMemoryUnitPriceTextField(){ return minMemoryUnitPriceTextField; }
	public void setMinMemoryUnitPriceTextField( JTextField minMemoryUnitPriceTextField ){ this.minMemoryUnitPriceTextField = minMemoryUnitPriceTextField; }
	
	private JTextField maxMemoryUnitPriceTextField;
	public JTextField getMaxMemoryUnitPriceTextField(){ return maxMemoryUnitPriceTextField; }
	public void setMaxMemoryUnitPriceTextField( JTextField maxMemoryUnitPriceTextField ){ this.maxMemoryUnitPriceTextField = maxMemoryUnitPriceTextField; }
		
	private JLabel diskSpaceLabel;
	public JLabel getDiskSpaceLabel(){ return diskSpaceLabel; }
	public void setDiskSpaceLabel( JLabel diskSpaceLabel ){ this.diskSpaceLabel = diskSpaceLabel; }
	
	private JTextField minDiskSpaceTextField;
	public JTextField getMinDiskSpaceTextField(){ return minDiskSpaceTextField; }
	public void setMinDiskSpaceTextField( JTextField minDiskSpaceTextField ){ this.minDiskSpaceTextField = minDiskSpaceTextField; }
	
	private JTextField maxDiskSpaceTextField;
	public JTextField getMaxDiskSpaceTextField(){ return maxDiskSpaceTextField; }
	public void getMaxDiskSpaceTextField( JTextField maxDiskSpaceTextField ){ this.maxDiskSpaceTextField = maxDiskSpaceTextField; }
	
	private JLabel diskSpaceUnitPriceLabel;
	public JLabel getDiskSpaceUnitPriceLabel(){ return diskSpaceUnitPriceLabel; }
	public void setDiskSpaceUnitPriceLabel( JLabel diskSpaceUnitPriceLabel ){ this.diskSpaceUnitPriceLabel = diskSpaceUnitPriceLabel; }
	
	private JTextField minDiskSpaceUnitPriceTextField;
	public JTextField getMinDiskSpaceUnitPriceTextField(){ return minDiskSpaceUnitPriceTextField; }
	public void setMinDiskSpaceUnitPriceTextField( JTextField minDiskSpaceUnitPriceTextField ){ this.minDiskSpaceUnitPriceTextField = minDiskSpaceUnitPriceTextField; }

	private JTextField maxDiskSpaceUnitPriceTextField;
	public JTextField getMaxDiskSpaceUnitPriceTextField(){ return maxDiskSpaceUnitPriceTextField; }
	public void setMaxDiskSpaceUnitPriceTextField( JTextField maxDiskSpaceUnitPriceTextField ){ this.maxDiskSpaceUnitPriceTextField = maxDiskSpaceUnitPriceTextField; }
	
	private JLabel maxVirtualNodesNumberLabel;
	public JLabel getMaxVirtualNodesNumberLabel(){ return maxVirtualNodesNumberLabel; }
	public void setMaxVirtualNodesNumberLabel( JLabel maxVirtualNodesNumberLabel ){ this.maxVirtualNodesNumberLabel = maxVirtualNodesNumberLabel; }
	
	private JTextField maxVirtualNodesNumberTextField;
	public JTextField getMaxVirtualNodesNumberTextField(){ return maxVirtualNodesNumberTextField; }
	public void setMaxVirtualNodesNumberTextField( JTextField maxVirtualNodesNumberTextField ){ this.maxVirtualNodesNumberTextField = maxVirtualNodesNumberTextField; }
	
	private JLabel bandwidthLabel;
	public JLabel getBandwidthLabel(){ return bandwidthLabel; }
	public void setBandwidthLabel( JLabel bandwidthLabel ){ this.bandwidthLabel = bandwidthLabel; }
	
	private JTextField minBandwidthTextField;
	public JTextField getMinBandwidthTextField(){ return minBandwidthTextField; }
	public void setMinBandwidthTextField( JTextField minBandwidthTextField ){ this.minBandwidthTextField = minBandwidthTextField; }
    
	private JTextField maxBandwidthTextField;
	public JTextField getMaxBandwidthTextField(){ return maxBandwidthTextField; }
	public void getMaxBandwidthTextField( JTextField maxBandwidthTextField ){ this.maxBandwidthTextField = maxBandwidthTextField; }

	private JLabel bandwidthUnitPriceLabel;
	public JLabel getBandwidthUnitPriceLabel(){ return bandwidthUnitPriceLabel; }
	public void setBandwidthUnitPriceLabel( JLabel bandwidthUnitPriceLabel ){ this.bandwidthUnitPriceLabel = bandwidthUnitPriceLabel; }
	
	private JTextField minBandwidthUnitPriceTextField;
	public JTextField getMinBandwidthUnitPriceTextField(){ return minBandwidthUnitPriceTextField; }
	public void setMinBandwidthUnitPriceTextField( JTextField minBandwidthUnitPriceTextField ){ this.minBandwidthUnitPriceTextField = minBandwidthUnitPriceTextField; }	
	
	private JTextField maxBandwidthUnitPriceTextField;
	public JTextField getMaxBandwidthUnitPriceTextField(){ return maxBandwidthUnitPriceTextField; }
	public void setMaxBandwidthUnitPriceTextField( JTextField maxBandwidthUnitPriceTextField ){ this.maxBandwidthUnitPriceTextField = maxBandwidthUnitPriceTextField; }
	
	private JLabel distanceLabel;
	public JLabel getDistanceLabel(){ return distanceLabel; }
	public void setDistanceLabel( JLabel distanceLabel ){ this.distanceLabel = distanceLabel; }
	
	private JTextField minDistanceTextField;
	public JTextField getMinDistanceTextField(){ return minDistanceTextField; }
	public void setMinDistanceTextField( JTextField minDistanceTextField ){ this.minDistanceTextField = minDistanceTextField; }
    
	private JTextField maxDistanceTextField;
	public JTextField getMaxDistanceTextField(){ return maxDistanceTextField; }
	public void setMaxDistanceTextField( JTextField maxDistanceTextField ){ this.maxDistanceTextField = maxDistanceTextField; }
	
	private JLabel informationLabel;
	public JLabel getInformationLabel(){ return informationLabel; }
	public void setInformationLabel( JLabel informationLabel ){ this.informationLabel = informationLabel; }
	
	public CreatePhysicalNetworksSelectPanel()
    {   
    	this.setLayout( new BorderLayout() );
        this.add( this.titlePanel(), BorderLayout.NORTH );
        this.add( this.contentPanel(), BorderLayout.CENTER );
    }
	private JPanel titlePanel()
	{
        JLabel titleLabel = new JLabel( "Random physical networks" );
        titleLabel.setFont( new Font( "MS Sans Serif", Font.BOLD, 14 ) );
        titleLabel.setBorder( new EmptyBorder( new Insets( 10, 10, 10, 10 ) ) );
        titleLabel.setOpaque( true );
        
        JPanel titlePanel = new JPanel();
        titlePanel.setLayout( new BorderLayout() );
        titlePanel.setBackground( Color.gray );
        titlePanel.add( titleLabel, BorderLayout.CENTER );
        titlePanel.add( new JSeparator(), BorderLayout.SOUTH );
        
        return titlePanel;
	}
	private JPanel contentPanel()
	{
		JPanel informationPanel = this.informationPanel();
		JPanel networksPanel = this.networksPanel();
		JPanel nodesPanel = this.nodesPanel();
		JPanel linksPanel = this.linksPanel();
		JPanel nodePanel = this.nodePanel();
		JPanel linkPanel = this.linkPanel();
		
        JPanel contentPanel = new JPanel();
        
		GroupLayout groupLayout = new GroupLayout( contentPanel );
		groupLayout.setAutoCreateGaps( true );
		groupLayout.setAutoCreateContainerGaps( true );
		groupLayout.setHorizontalGroup( groupLayout.createSequentialGroup().addGroup( groupLayout.createParallelGroup().addComponent( informationPanel ).addComponent( networksPanel ).addComponent( nodesPanel ).addComponent( linksPanel ).addComponent( nodePanel ).addComponent( linkPanel ) ) );
		groupLayout.setVerticalGroup( groupLayout.createParallelGroup().addGroup( groupLayout.createSequentialGroup().addComponent( informationPanel ).addComponent( networksPanel ).addComponent( nodesPanel ).addComponent( linksPanel ).addComponent( nodePanel ).addComponent( linkPanel ) ) );
		contentPanel.setLayout( groupLayout );
        
        return contentPanel;
	}
	
    private JPanel informationPanel()
	{
		this.setInformationLabel( new JLabel() );
		
		JPanel informationPanel = new JPanel();
		informationPanel.add( this.getInformationLabel() );
		
		return informationPanel;
	}
	
	private JPanel networksPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>PHYSICAL NETWORKS</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel networksPanel = new JPanel();
        networksPanel.setLayout( new GridLayout( 0, 1 ) );
        networksPanel.setBorder( titledBorder );
        networksPanel.add( this.networksNumberPanel() );
        
        return networksPanel;
	}
    private JPanel networksNumberPanel()
    {
    	this.setNetworksNumberLabel( new JLabel( "<html><b>Networks number:</b></html>" ) );
    	this.setNetworksNumberTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.NETWORKS_NUMBER ) ) );
    	this.getNetworksNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getNetworksNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel networksNumberPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        networksNumberPanel.add( this.getNetworksNumberLabel() );
        networksNumberPanel.add( this.getNetworksNumberTextField() );
        
        return networksNumberPanel;
    }
    
    private JPanel nodesPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>PHYSICAL NODES</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel nodesPanel = new JPanel();
        nodesPanel.setLayout( new GridLayout( 0, 1 ) );
        nodesPanel.setBorder( titledBorder );
        nodesPanel.add( this.nodesNumberRangePanel() );
        nodesPanel.add( this.typesPercentagesPanel() );
        nodesPanel.add( this.operatingSystemsPercentagesPanel() );
        nodesPanel.add( this.virtualEnvironmentsPercentagesPanel() );
        
        return nodesPanel;
	}
    private JPanel nodesNumberRangePanel()
    {
    	this.setNodesNumberLabel( new JLabel( "<html><b>Nodes number:</b></html>" ) );
    	
    	this.setMinNodesNumberTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MIN_NODES_NUMBER ) ) );
        this.getMinNodesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMinNodesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
        this.setMaxNodesNumberTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MAX_NODES_NUMBER ) ) );
        this.getMaxNodesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMaxNodesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel nodesNumberRangePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	nodesNumberRangePanel.add( this.getNodesNumberLabel() );
    	nodesNumberRangePanel.add( new JLabel( "Between" ) );
    	nodesNumberRangePanel.add( this.getMinNodesNumberTextField() );
        nodesNumberRangePanel.add( new JLabel( "and" ) );
        nodesNumberRangePanel.add( this.getMaxNodesNumberTextField() );
        
        return nodesNumberRangePanel;
    }
    private JPanel typesPercentagesPanel()
    {
    	this.setTypesNodePercentagesLabel( new JLabel( "<html><b>Types %:</b></html>" ) );
    	
    	this.setRoutersPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.ROUTERS_PERCENTAGE ) ) );
    	this.getRoutersPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getRoutersPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setSwitchesPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.SWITCHES_PERCENTAGE ) ) );
    	this.getSwitchesPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getSwitchesPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setServersPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.SERVERS_PERCENTAGE ) ) );
    	this.getServersPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getServersPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel typesPercentagesPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	
    	typesPercentagesPanel.add( this.getTypesNodePercentagesLabel() );
    	
    	typesPercentagesPanel.add( new JLabel( "Routers:" ) );
    	typesPercentagesPanel.add( this.getRoutersPercentageTextField() );
    	
    	typesPercentagesPanel.add( new JLabel( "Switches:" ) );
    	typesPercentagesPanel.add( this.getSwitchesPercentageTextField() );
    	
    	typesPercentagesPanel.add( new JLabel( "Servers:" ) );
    	typesPercentagesPanel.add( this.getServersPercentageTextField() );
    	
    	return typesPercentagesPanel;
    }
    private JPanel operatingSystemsPercentagesPanel()
    {
    	this.setOperatingSystemsLabel( new JLabel( "<html><b>Operating systems %:</b></html>" ) );
    	    	
    	this.setLinuxPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.LINUX_PERCENTAGE ) ) );
    	this.getLinuxPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getLinuxPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setWindowsPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.WINDOWS_PERCENTAGE ) ) );
    	this.getWindowsPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getWindowsPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setSolarisPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.SOLARIS_PERCENTAGE ) ) );
    	this.getSolarisPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getSolarisPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.getAndroidPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.ANDROID_PERCENTAGE ) ) );
    	this.getAndroidPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getAndroidPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel operatingSystemsPercentagePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	
    	operatingSystemsPercentagePanel.add( this.getOperatingSystemsLabel() );
    	
    	operatingSystemsPercentagePanel.add( new JLabel( "Linux:" ) );
    	operatingSystemsPercentagePanel.add( this.getLinuxPercentageTextField() );
    	
    	operatingSystemsPercentagePanel.add( new JLabel( "Windows:" ) );
    	operatingSystemsPercentagePanel.add( this.getWindowsPercentageTextField() );
    	
    	operatingSystemsPercentagePanel.add( new JLabel( "Solaris:" ) );
    	operatingSystemsPercentagePanel.add( this.getSolarisPercentageTextField() );
    	
    	operatingSystemsPercentagePanel.add( new JLabel( "Android:" ) );
    	operatingSystemsPercentagePanel.add( this.getAndroidPercentageTextField() );
    	
    	return operatingSystemsPercentagePanel;
    }
    private JPanel virtualEnvironmentsPercentagesPanel()
    {
    	this.setVirtualEnvironmentsLabel( new JLabel( "<html><b>Virtual environments %:</b></html>" ) );
    	    	
    	this.setVmWarePercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.VMWARE_PERCENTAGE ) ) );
    	this.getVmWarePercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getVmWarePercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setXenPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.XEN_PERCENTAGE ) ) );
    	this.getXenPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getXenPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.getKvmPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.KVM_PERCENTAGE ) ) );
    	this.getKvmPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getKvmPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.getUmlPercentageTextField( new JTextField( Integer.toString( PhysicalNodesFactory.UML_PERCENTAGE ) ) );
    	this.getUmlPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getUmlPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel virtualEnvironmentsPercentagePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	virtualEnvironmentsPercentagePanel.add( this.getVirtualEnvironmentsLabel() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "VMware:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getVmWarePercentageTextField() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "Xen:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getXenPercentageTextField() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "KVM:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getKvmPercentageTextField() );
    	virtualEnvironmentsPercentagePanel.add( new JLabel( "UML:" ) );
    	virtualEnvironmentsPercentagePanel.add( this.getUmlPercentageTextField() );
    	
    	return virtualEnvironmentsPercentagePanel;
    }
    
    private JPanel linksPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>PHYSICAL LINKS</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel linksPanel = new JPanel();
        linksPanel.setLayout( new GridLayout( 0, 1 ) );
        linksPanel.setBorder( titledBorder );
        linksPanel.add( this.linksNumberPercentagePanel() );
        linksPanel.add( this.linksNumberRangePanel() );
        
    	ButtonGroup linksNumberButtonGroup = new ButtonGroup();
        linksNumberButtonGroup.add( this.getLinksNumberPercentageRadioButton() );
    	linksNumberButtonGroup.add( this.getLinksNumberRangeRadioButton() );
        
        return linksPanel;
	}
    private JPanel linksNumberPercentagePanel()
    {
    	this.setLinksNumberPercentageRadioButton( new JRadioButton( "<html><b>Links number between nodes %:</b></html>"  ) );
    	this.getLinksNumberPercentageRadioButton().setSelected( true );
    	
    	this.setLinksNumberPercentageTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.LINKS_NUMBER_PERCENTAGE ) ) );
    	this.getLinksNumberPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getLinksNumberPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.getLinksNumberPercentageTextField().setEnabled( true );
    	
        JPanel linksNumberPercentagePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );        
        linksNumberPercentagePanel.add( this.getLinksNumberPercentageRadioButton() );
        linksNumberPercentagePanel.add( this.getLinksNumberPercentageTextField() );
        
        return linksNumberPercentagePanel;
    }
    private JPanel linksNumberRangePanel()
    {   
    	this.setLinksNumberRangeRadioButton( new JRadioButton( "<html><b>Links number per node:</b></html>" ) );    	
    	this.getLinksNumberRangeRadioButton().setSelected( false );
        
    	this.setMinLinksNumberTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MIN_LINKS_NUMBER_RANGE ) ) );
    	this.getMinLinksNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinLinksNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.getMinLinksNumberTextField().setEnabled( false );
    	
    	this.setMaxLinksNumberTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MAX_LINKS_NUMBER_RANGE ) ) );
    	this.getMaxLinksNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxLinksNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.getMaxLinksNumberTextField().setEnabled( false );
    	
    	JPanel linksNumberRangePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        linksNumberRangePanel.add( this.getLinksNumberRangeRadioButton() );
        linksNumberRangePanel.add( new JLabel( "Between" ) );
        linksNumberRangePanel.add( this.getMinLinksNumberTextField() );
        linksNumberRangePanel.add( new JLabel( "and" ) );
        linksNumberRangePanel.add( this.getMaxLinksNumberTextField() );
    	
    	return linksNumberRangePanel;
    }
    
    private JPanel nodePanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>PHYSICAL NODE</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel nodePanel = new JPanel();
        nodePanel.setLayout( new GridLayout( 0, 1 ) );
        nodePanel.setBorder( titledBorder );
        nodePanel.add( this.cpuPanel() );
        nodePanel.add( this.memoryPanel() );
        nodePanel.add( this.diskSpacePanel() );
        nodePanel.add( this.maxVirtualNodesNumberPanel() );
        
        return nodePanel;
	}
    private JPanel cpuPanel()
    {
    	this.setCpuLabel( new JLabel( "<html><b>CPU:</b></html>" ) );
    	this.setMinCpuTextField( new JTextField( Integer.toString( PhysicalNodesFactory.MIN_CPU ) ) );
    	this.getMinCpuTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinCpuTextField().setHorizontalAlignment( JTextField.CENTER );    	
    	this.setMaxCpuTextField( new JTextField( Integer.toString( PhysicalNodesFactory.MAX_CPU ) ) );
    	this.getMaxCpuTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxCpuTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setCpuUnitPriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	this.setMinCpuUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MIN_CPU_PRICE_UNIT ) ) );
    	this.getMinCpuUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinCpuUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );    	
    	this.setMaxCpuUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MAX_CPU_PRICE_UNIT ) ) );
    	this.getMaxCpuUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxCpuUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel cpuPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	cpuPanel.add( this.getCpuLabel() );
    	cpuPanel.add( new JLabel( "Between" ) );
    	cpuPanel.add( this.getMinCpuTextField() );
    	cpuPanel.add( new JLabel( "and" ) );
    	cpuPanel.add( this.getMaxCpuTextField() );
    	cpuPanel.add( this.getCpuUnitPriceLabel() );
    	cpuPanel.add( new JLabel( "Between" ) );
    	cpuPanel.add( this.getMinCpuUnitPriceTextField() );
    	cpuPanel.add( new JLabel( "and" ) );
    	cpuPanel.add( this.getMaxCpuUnitPriceTextField() );
        
        return cpuPanel;
    }
    private JPanel memoryPanel()
    {
    	this.setMemoryLabel( new JLabel( "<html><b>Memory:</b></html>" ) );
    	this.setMinMemoryTextField( new JTextField( Integer.toString( PhysicalNodesFactory.MIN_MEMORY ) ) );
    	this.getMinMemoryTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinMemoryTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setMaxMemoryTextField( new JTextField( Integer.toString( PhysicalNodesFactory.MAX_MEMORY ) ) );
    	this.getMaxMemoryTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxMemoryTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMemoryUnitPriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	this.setMinMemoryUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MIN_MEMORY_PRICE_UNIT ) ) );
    	this.getMinMemoryUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinMemoryUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setMaxMemoryUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MAX_MEMORY_PRICE_UNIT ) ) );
    	this.getMaxMemoryUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxMemoryUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel memoryPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	memoryPanel.add( this.getMemoryLabel() );
    	memoryPanel.add( new JLabel( "Between" ) );
    	memoryPanel.add( this.getMinMemoryTextField() );
    	memoryPanel.add( new JLabel( "and" ) );
    	memoryPanel.add( this.getMaxMemoryTextField() );
    	memoryPanel.add( this.getMemoryUnitPriceLabel() );
    	memoryPanel.add( new JLabel( "Between" ) );
    	memoryPanel.add( this.getMinMemoryUnitPriceTextField() );
    	memoryPanel.add( new JLabel( "and" ) );
    	memoryPanel.add( this.getMaxMemoryUnitPriceTextField() );
        
        return memoryPanel;
    }
    private JPanel diskSpacePanel()
    {
    	this.setDiskSpaceLabel( new JLabel( "<html><b>Disk space:</b></html>" ) );
    	this.setMinDiskSpaceTextField( new JTextField( Integer.toString( PhysicalNodesFactory.MIN_DISK_SPACE ) ) );
    	this.getMinDiskSpaceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinDiskSpaceTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.getMaxDiskSpaceTextField( new JTextField( Integer.toString( PhysicalNodesFactory.MAX_DISK_SPACE ) ) );
    	this.getMaxDiskSpaceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxDiskSpaceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setDiskSpaceUnitPriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	this.setMinDiskSpaceUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MIN_DISK_SPACE_PRICE_UNIT ) ) );
    	this.getMinDiskSpaceUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinDiskSpaceUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setMaxDiskSpaceUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MAX_DISK_SPACE_PRICE_UNIT ) ) );
    	this.getMaxDiskSpaceUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxDiskSpaceUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel diskSpacePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	diskSpacePanel.add( this.getDiskSpaceLabel() );
    	diskSpacePanel.add( new JLabel( "Between" ) );
    	diskSpacePanel.add( this.getMinDiskSpaceTextField() );
    	diskSpacePanel.add( new JLabel( "and" ) );
    	diskSpacePanel.add( this.getMaxDiskSpaceTextField() );
    	diskSpacePanel.add( this.getDiskSpaceUnitPriceLabel() );
    	diskSpacePanel.add( new JLabel( "Between" ) );
    	diskSpacePanel.add( this.getMinDiskSpaceUnitPriceTextField() );
    	diskSpacePanel.add( new JLabel( "and" ) );
    	diskSpacePanel.add( this.getMaxDiskSpaceUnitPriceTextField() );
    	
    	return diskSpacePanel;
    }
    private JPanel maxVirtualNodesNumberPanel()
    {
    	this.setMaxVirtualNodesNumberLabel( new JLabel( "<html><b>Maximum virtual nodes number:</b></html>" )) ;
    	
    	this.setMaxVirtualNodesNumberTextField( new JTextField( Integer.toString( PhysicalNodesFactory.MAX_VIRTUAL_NODES_NUMBER ) ) );
    	this.getMaxVirtualNodesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxVirtualNodesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel maxVirtualNodesNumberPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        maxVirtualNodesNumberPanel.add( this.getMaxVirtualNodesNumberLabel() );
        maxVirtualNodesNumberPanel.add( this.getMaxVirtualNodesNumberTextField() );
        
        return maxVirtualNodesNumberPanel;
    }
    
    private JPanel linkPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>PHYSICAL LINK</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel linkPanel = new JPanel();
        linkPanel.setLayout( new GridLayout( 0, 1 ) );
        linkPanel.setBorder( titledBorder );
        linkPanel.add( this.bandwidthPanel() );
        linkPanel.add( this.distancePanel() );
        
        return linkPanel;
	}
    private JPanel bandwidthPanel()
    {
    	this.setBandwidthLabel( new JLabel( "<html><b>Bandwidth:</b></html>" ) );
    	
    	this.setMinBandwidthTextField( new JTextField( Integer.toString( PhysicalLinksFactory.MIN_BANDWIDTH ) ) );
    	this.getMinBandwidthTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBandwidthTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.getMaxBandwidthTextField( new JTextField( Integer.toString( PhysicalLinksFactory.MAX_BANDWIDTH ) ) );
    	this.getMaxBandwidthTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBandwidthTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setBandwidthUnitPriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	
    	this.setMinBandwidthUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MIN_BANDWIDTH_PRICE_UNIT ) ) );
    	this.getMinBandwidthUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBandwidthUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxBandwidthUnitPriceTextField( new JTextField( Integer.toString( PhysicalNetworksFactory.MAX_BANDWIDTH_PRICE_UNIT ) ) );
    	this.getMaxBandwidthUnitPriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBandwidthUnitPriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel bandwidthPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        bandwidthPanel.add( this.getBandwidthLabel() );
        bandwidthPanel.add( new JLabel( "Between" ) );
        bandwidthPanel.add( this.getMinBandwidthTextField() );
        bandwidthPanel.add( new JLabel( "and" ) );
        bandwidthPanel.add( this.getMaxBandwidthTextField() );
        bandwidthPanel.add( this.getBandwidthUnitPriceLabel() );
        bandwidthPanel.add( new JLabel( "Between" ) );
        bandwidthPanel.add( this.getMinBandwidthUnitPriceTextField() );
        bandwidthPanel.add( new JLabel( "and" ) );
        bandwidthPanel.add( this.getMaxBandwidthUnitPriceTextField() );
        
        return bandwidthPanel;
    }
    private JPanel distancePanel()
    {
    	this.setDistanceLabel( new JLabel( "<html><b>Distance:</b></html>" ) );
    	
    	this.setMinDistanceTextField( new JTextField( Integer.toString( PhysicalLinksFactory.MIN_DISTANCE ) ) );
    	this.getMinDistanceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinDistanceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxDistanceTextField( new JTextField( Integer.toString( PhysicalLinksFactory.MAX_DISTANCE ) ) );
    	this.getMaxDistanceTextField().setPreferredSize( new Dimension( 30, 20 ) );
    	this.getMinDistanceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel distancePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        distancePanel.add( this.getDistanceLabel() );
        distancePanel.add( new JLabel( "Between" ) );
        distancePanel.add( this.getMinDistanceTextField() );
        distancePanel.add( new JLabel( "and" ) );
        distancePanel.add( this.getMaxDistanceTextField() );
        
        return distancePanel;
    }
        
	public void addListeners( DocumentListener documentListener, ActionListener actionListener )
	{
		this.getNetworksNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinNodesNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxNodesNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getRoutersPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getSwitchesPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getServersPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getLinuxPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getWindowsPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getSolarisPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getAndroidPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getVmWarePercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getXenPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getKvmPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getUmlPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinCpuTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxCpuTextField().getDocument().addDocumentListener( documentListener );
		this.getMinCpuUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxCpuUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinMemoryTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxMemoryTextField().getDocument().addDocumentListener( documentListener );
		this.getMinMemoryUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxMemoryUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinDiskSpaceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxDiskSpaceTextField().getDocument().addDocumentListener( documentListener );
		this.getMinDiskSpaceUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxDiskSpaceUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMaxVirtualNodesNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getLinksNumberRangeRadioButton().addActionListener( actionListener );
		this.getLinksNumberPercentageRadioButton().addActionListener( actionListener );
		this.getMinLinksNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxLinksNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getLinksNumberPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinBandwidthTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxBandwidthTextField().getDocument().addDocumentListener( documentListener );
		this.getMinBandwidthUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxBandwidthUnitPriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinDistanceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxDistanceTextField().getDocument().addDocumentListener( documentListener );
	}
    
	public void refreshLinksNumberRadioButton()
	{
		this.getMinLinksNumberTextField().setEnabled( false );
		this.getMaxLinksNumberTextField().setEnabled( false );
		
		this.getLinksNumberPercentageTextField().setEnabled( false );
		
		if( this.getLinksNumberRangeRadioButton().isSelected() )
		{
			this.getMinLinksNumberTextField().setEnabled( true );
			this.getMaxLinksNumberTextField().setEnabled( true );
		}
		else
		{
			this.getLinksNumberPercentageTextField().setEnabled( true );
		}
	}
	
	public boolean check()
	{
		this.getInformationLabel().setText( "Press \"Next\" to create random physical networks" );
		this.getInformationLabel().setForeground( Color.BLACK );
		
		if(      !this.checkNetworksNumber() )					return false;
		else if( !this.checkNodesNumber() )						return false;
		else if( !this.checkTypesPercentages() )				return false;
		else if( !this.checkOperatingSystemsPercentages() )		return false;
		else if( !this.checkVirtualEnvironmentsPercentages() )	return false;
		else if( !this.checkCpu() )								return false;
		else if( !this.checkCpuUnitPrice() )					return false;
		else if( !this.checkMemory() )							return false;
		else if( !this.checkMemoryUnitPrice() )					return false;
		else if( !this.checkDiskSpace() )						return false;
		else if( !this.checkDiskSpaceUnitPrice() )				return false;
		else if( !this.checkMaxVirtualNodesNumber() )			return false;
		else if( !this.checkLinksNumber() )						return false;
		else if( !this.checkBandwidth() )						return false;
		else if( !this.checkBandwidthUnitPrice() )				return false;
		else if( !this.checkDistance() )						return false;
		else 													return true;
	}
	
	private boolean checkNetworksNumber()
	{	
		int lowestNetworksNumber =  1;
		int highestNetworksNumber = 50;
		
		try
		{
			int networksNumber = Integer.parseInt( this.getNetworksNumberTextField().getText() );
			
			if( !( lowestNetworksNumber <= networksNumber && networksNumber <= highestNetworksNumber ) )
				throw new NumberFormatException();
			
			this.getNetworksNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestNetworksNumber + " and " + highestNetworksNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getNetworksNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	
	private boolean checkNodesNumber()
	{
		int lowestMinNodesNumber = 2;
		int highestMaxNodesNumber = 50;
		
		try
		{
			int minNodesNumber = Integer.parseInt( this.getMinNodesNumberTextField().getText() );
			int maxNodesNumber  = Integer.parseInt( this.getMaxNodesNumberTextField().getText() );
			
			if( !( lowestMinNodesNumber <= minNodesNumber && minNodesNumber <= maxNodesNumber && maxNodesNumber <= highestMaxNodesNumber ) )
				throw new NumberFormatException();
			
			this.getNodesNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinNodesNumber + " and maximum value " + highestMaxNodesNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getNodesNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkTypesPercentages()
	{	
		try
		{
			int routersPercentage = Integer.parseInt( this.getRoutersPercentageTextField().getText() );
			int switchesPercentage = Integer.parseInt( this.getSwitchesPercentageTextField().getText() );
			int serversPercentage = Integer.parseInt( this.getServersPercentageTextField().getText() );
			
			if( !( 0 <= routersPercentage  && routersPercentage  <= 100 ) || 
				!( 0 <= switchesPercentage && switchesPercentage <= 100 ) ||
				!( 0 <= serversPercentage  && serversPercentage  <= 100 ) || 
				!( routersPercentage + switchesPercentage + serversPercentage == 100 ) )
				throw new NumberFormatException();
			
			this.getTypesNodePercentagesLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Type of nodes must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getTypesNodePercentagesLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkOperatingSystemsPercentages()
	{
		try
		{
			int linuxPercentage   = Integer.parseInt( this.getLinuxPercentageTextField().getText() );
			int windowsPercentage = Integer.parseInt( this.getWindowsPercentageTextField().getText() );
			int solarisPercentage = Integer.parseInt( this.getSolarisPercentageTextField().getText() );
			int androidPercentage = Integer.parseInt( this.getAndroidPercentageTextField().getText() );
								
			if( !( 0 <= linuxPercentage   && linuxPercentage   <= 100 ) || 
				!( 0 <= windowsPercentage && windowsPercentage <= 100 ) || 
				!( 0 <= solarisPercentage && solarisPercentage <= 100 ) || 
				!( 0 <= androidPercentage && androidPercentage <= 100 ) || 
				!( linuxPercentage + windowsPercentage + solarisPercentage + androidPercentage == 100 ) )
				throw new NumberFormatException();
			
			this.getOperatingSystemsLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Operating systems of nodes must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getOperatingSystemsLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkVirtualEnvironmentsPercentages()
	{	
		try
		{
			int vmWarePercentage = Integer.parseInt( this.getVmWarePercentageTextField().getText() );
			int xenPercentage    = Integer.parseInt( this.getXenPercentageTextField().getText() );
			int kvmPercentage    = Integer.parseInt( this.getKvmPercentageTextField().getText() );
			int umlPercentage    = Integer.parseInt( this.getUmlPercentageTextField().getText() );
			
			if( !( 0 <= vmWarePercentage && vmWarePercentage <= 100 ) || 
				!( 0 <= xenPercentage && xenPercentage <= 100 ) || 
				!( 0 <= kvmPercentage && kvmPercentage <= 100 ) || 
				!( 0 <= umlPercentage && umlPercentage <= 100 ) || 
				!( vmWarePercentage + xenPercentage + kvmPercentage + umlPercentage == 100 ) )
				throw new NumberFormatException();
			
			this.getVirtualEnvironmentsLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Virtual environments of nodes must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getVirtualEnvironmentsLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    
    private boolean checkLinksNumber()
	{
    	if( this.getLinksNumberRangeRadioButton().isSelected() )
    		return this.checkLinksNumberRange();
			
		else if( this.getLinksNumberPercentageRadioButton().isSelected() )
			return this.checkLinksNumberPercentage();
		
		return true;		
	}
	private boolean checkLinksNumberPercentage()
	{
		int minLinksNumberPercentage =  15;
		int maxLinksNumberPercentage = 100;
		
		try
		{
			int linksNumberPercentage = Integer.parseInt( this.getLinksNumberPercentageTextField().getText() );
			
			if( !( minLinksNumberPercentage <= linksNumberPercentage && linksNumberPercentage <= maxLinksNumberPercentage ) )
				throw new NumberFormatException();
			
			this.getLinksNumberPercentageRadioButton().setForeground( Color.BLACK );
			
			return true;
			
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + minLinksNumberPercentage + " and " + maxLinksNumberPercentage + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getLinksNumberPercentageRadioButton().setForeground( Color.RED );
			
			return false;
		}
	}
	private boolean checkLinksNumberRange()
	{
		int lowestMinLinksNumber = 1;
		int highestMaxLinksNumber = 50;
		
		try
		{
			int minLinksNumber = Integer.parseInt( this.getMinLinksNumberTextField().getText() );
			int maxLinksNumber = Integer.parseInt( this.getMaxLinksNumberTextField().getText() );
			
			if( !( lowestMinLinksNumber <= minLinksNumber && minLinksNumber <= maxLinksNumber && maxLinksNumber <= highestMaxLinksNumber ) )
				throw new NumberFormatException();
			
			this.getLinksNumberRangeRadioButton().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value "+lowestMinLinksNumber+" and maximum value "+highestMaxLinksNumber+"</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getLinksNumberRangeRadioButton().setForeground( Color.RED );
			
			return false;
		}
	}
	
    private boolean checkCpu()
    {
    	int lowestMinCpu = 0;
    	int highestMaxCpu = 100;
    	
		try
		{
			int minCpu = Integer.parseInt( this.getMinCpuTextField().getText() );
			int maxCpu = Integer.parseInt( this.getMaxCpuTextField().getText() );
			
			if( !( lowestMinCpu <= minCpu && minCpu <= maxCpu && maxCpu <= highestMaxCpu ) )
				throw new NumberFormatException();
			
			this.getCpuLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinCpu + " and maximum value " + highestMaxCpu + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getCpuLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkCpuUnitPrice()
    {	
    	int lowestMinCpuUnitPrice = 0;
    	int highestMaxCpuUnitPrice = 100;
    	
		try
		{
			int minCpuUnitPrice = Integer.parseInt( this.getMinCpuUnitPriceTextField().getText() );
			int maxCpuUnitPrice = Integer.parseInt( this.getMaxCpuUnitPriceTextField().getText() );
			
			if( !( lowestMinCpuUnitPrice <= minCpuUnitPrice && minCpuUnitPrice <= maxCpuUnitPrice && maxCpuUnitPrice <= highestMaxCpuUnitPrice ) )
				throw new NumberFormatException();
			
			this.getCpuUnitPriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinCpuUnitPrice + " and maximum value " + highestMaxCpuUnitPrice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getCpuUnitPriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    
    private boolean checkMemory()
    {
    	int lowestMinMemory = 0;
    	int highestMaxMemory = 100;
    	
		try
		{
			int minMemory = Integer.parseInt( this.getMinMemoryTextField().getText() );
			int maxMemory = Integer.parseInt( this.getMaxMemoryTextField().getText() );
			
			if( !( lowestMinMemory <= minMemory && minMemory <= maxMemory && maxMemory <= 100 ) )
				throw new NumberFormatException();
			
			this.getMemoryLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinMemory + " and maximum value " + highestMaxMemory + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getMemoryLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkMemoryUnitPrice()
    {	
    	int lowestMinMemoryUnitPrice = 0;
    	int highestMaxMemoryUnitPrice = 100;
    	
		try
		{
			int minMemoryUnitPrice = Integer.parseInt( this.getMinMemoryUnitPriceTextField().getText() );
			int maxMemoryUnitPrice = Integer.parseInt( this.getMaxMemoryUnitPriceTextField().getText() );
			
			if( !( lowestMinMemoryUnitPrice <= minMemoryUnitPrice && minMemoryUnitPrice <= maxMemoryUnitPrice && maxMemoryUnitPrice <= highestMaxMemoryUnitPrice ) )
				throw new NumberFormatException();
			
			this.getMemoryUnitPriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinMemoryUnitPrice + " and maximum value " + highestMaxMemoryUnitPrice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getMemoryUnitPriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    
    private boolean checkDiskSpace()
    {
    	int lowestMinDiskSpace = 0;
    	int highestMaxDiskSpace = 100;
    	
		try
		{
			int minDiskSpace = Integer.parseInt( this.getMinDiskSpaceTextField().getText() );
			int maxDiskSpace = Integer.parseInt( this.getMaxDiskSpaceTextField().getText() );
			
			if( !( lowestMinDiskSpace <= minDiskSpace && minDiskSpace <= maxDiskSpace && maxDiskSpace <= highestMaxDiskSpace ) )
				throw new NumberFormatException();
			
			this.getDiskSpaceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinDiskSpace + " and maximum value " + highestMaxDiskSpace + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getDiskSpaceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkDiskSpaceUnitPrice()
    {	
    	int lowestMinDiskSpaceUnitPrice = 0;
    	int highestMaxDiskSpaceUnitPrice = 100;
    	
		try
		{
			int minDiskSpaceUnitPrice = Integer.parseInt( this.getMinDiskSpaceUnitPriceTextField().getText() );
			int maxDiskSpaceUnitPrice = Integer.parseInt( this.getMaxDiskSpaceUnitPriceTextField().getText() );
			
			if( !( lowestMinDiskSpaceUnitPrice <= minDiskSpaceUnitPrice && minDiskSpaceUnitPrice <= maxDiskSpaceUnitPrice && maxDiskSpaceUnitPrice <= highestMaxDiskSpaceUnitPrice ) )
				throw new NumberFormatException();
			
			this.getDiskSpaceUnitPriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinDiskSpaceUnitPrice + " and maximum value " + highestMaxDiskSpaceUnitPrice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getDiskSpaceUnitPriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    
	private boolean checkMaxVirtualNodesNumber()
	{	
		int lowestMaxVirtualNodesNumber = 1;
		int highestMaxVirtualNodesNumber = 50;
		
		try
		{
			int maxVirtualNodesNumber = Integer.parseInt( this.getMaxVirtualNodesNumberTextField().getText() );
			
			if( !( lowestMaxVirtualNodesNumber <= maxVirtualNodesNumber && maxVirtualNodesNumber <= highestMaxVirtualNodesNumber ) )
				throw new NumberFormatException();
			
			this.getMaxVirtualNodesNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestMaxVirtualNodesNumber + " and " + highestMaxVirtualNodesNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getMaxVirtualNodesNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    
    private boolean checkBandwidth()
    {
    	int lowestMinBandwidth = 0;
    	int highestMaxBandwidth = 100;
    	
		try
		{
			int minBandwidth = Integer.parseInt( this.getMinBandwidthTextField().getText() );
			int maxBandwidth = Integer.parseInt( this.getMaxBandwidthTextField().getText() );
			
			if( !( lowestMinBandwidth <= minBandwidth && minBandwidth <= maxBandwidth && maxBandwidth <= highestMaxBandwidth ) )
				throw new NumberFormatException();
			
			this.getBandwidthLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinBandwidth + " and maximum value " + highestMaxBandwidth + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getBandwidthLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkBandwidthUnitPrice()
    {	
    	int lowestMinBandwidthUnitPrice = 0;
    	int highestMaxBandwidthUnitPrice = 100;
    	
		try
		{
			int minBandwidthUnitPrice = Integer.parseInt( this.getMinBandwidthUnitPriceTextField().getText() );
			int maxBandwidthUnitPrice = Integer.parseInt( this.getMaxBandwidthUnitPriceTextField().getText() );
			
			if( !( lowestMinBandwidthUnitPrice <= minBandwidthUnitPrice && minBandwidthUnitPrice <= maxBandwidthUnitPrice && maxBandwidthUnitPrice <= highestMaxBandwidthUnitPrice ) )
				throw new NumberFormatException();
			
			this.getBandwidthUnitPriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinBandwidthUnitPrice + " and maximum value " + highestMaxBandwidthUnitPrice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getBandwidthUnitPriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
	
    private boolean checkDistance()
    {
    	int lowestMinDistance = 1;
    	int highetsMaxDistance = 100;
    	
		try
		{
			int minDistance = Integer.parseInt( this.getMinDistanceTextField().getText() );
			int maxDistance = Integer.parseInt( this.getMaxDistanceTextField().getText() );
			
			if( !( lowestMinDistance <= minDistance && minDistance <= maxDistance && maxDistance <= highetsMaxDistance ) )
				throw new NumberFormatException();
			
			this.getDistanceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinDistance + " and maximum value " + highetsMaxDistance + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getDistanceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
	
}
